<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Zentia</title>
	<link href="/public/icon.png" rel="icon" type="image/x-icon">
	<link href="/public/admin/layui/css/layui.css" rel="stylesheet">
	<link href="/public/index/css/game.css" rel="stylesheet">
</head>
<body>
	<div class="subject">
		<img class="login" src="/public/index/image/login.jpg"><br/>
		<div class="mainfont">
			<p>月冷千山，寒江自碧，只影向谁去？</p>
			<p>万丈冰崖，雪莲花落，片片如星雨。</p>
			<p>人影肥瘦，玉蟾圆缺，昆仑千秋雪。</p>
			<p>斜斟北斗，细饮银河，共我醉明月。</p>
		</div>
		<form id="doLogin" class="form" action='{:url("login")}' method="post">
			<p><span>账号：</span><input type="text" id="username" name="username" required oninvalid="setCustomValidity('请输入账号');" oninput="setCustomValidity('');"></p>
			<p><span>密码：</span><input type="password" id="password" name="password" required oninvalid="setCustomValidity('请输入密码');" oninput="setCustomValidity('');"></p>
			<p class="ctr">
				<input type="submit" id="submit" name="submit" value="登陆">
				<a id="btn" href='{:url("register")}'>注册</a>
			</p>
		</form>
		<p class="updateLog" style="display: none"><a href='{:url("log/index")}'>更新日志</a></p>
	</div>
	<!-- / -->
	<script src="/public/index/js/jquery-1.11.1.min.js"></script>
	<script src="/public/admin/layui/layui.js"></script>
	<script src="/public/index/js/jquery.form.js"></script>
	<script type="text/javascript">
		$(function(){
			$('#doLogin').ajaxForm({
				//beforeSubmit: checkForm,	// 此方法主要是提交前执行的方法，根据需要设置
				success: complete,			// 这是提交后的方法
				dataType: 'json'
			});
			function checkForm(){
				console.log('验证表单');
				layui.use("layer",function(){
					if( '' == $.trim($('#username').val())){
						layer.msg('请输入用户名', {icon: 5,time:2000}, function(index){
							layer.close(index);
						});
						return false;
					}
					if( '' == $.trim($('#password').val())){
						layer.msg('请输入密码', {icon: 5,time:2000}, function(index){
							layer.close(index);
						});
						return false;
					}
				});
			}
			function complete(data){
				console.log(data);
				layui.use("layer",function(){
					if(data.code==1){
						layer.msg(data.msg, {icon: 6,time:1000}, function(index){
							layer.close(index);
							window.location.href = data.data.url;
						});
					}else{
						layer.msg(data.msg, {icon: 5,time:2000});
						return false;
					}
				});
			}
		});
	</script>
</body>
</html>
